package gmusic.bo;

import java.io.File;

import algutil.texte.ConversionTexte;

public class ReleaseDirectoryBean {

	private File directoryRelease = null;

	private String artistName = null;

	private String year = null;

	private String releaseName = null;

	private String complementaryInfo = null;

	public ReleaseDirectoryBean() {

	}

	public ReleaseDirectoryBean(File directoryRelease) {
		this.directoryRelease = directoryRelease;
		String directoryReleaseName = directoryRelease.getName();

		artistName = directoryReleaseName.substring(0,
				directoryReleaseName.indexOf("-")).trim();

		year = directoryReleaseName.substring(
				directoryReleaseName.indexOf("-") + 1,
				directoryReleaseName.indexOf("-") + 6).trim();

		if (directoryRelease.getName().indexOf("[") != -1) {
			releaseName = directoryReleaseName.substring(
					directoryReleaseName.indexOf("-") + 7,
					directoryReleaseName.indexOf("[")).trim();

			complementaryInfo = directoryReleaseName.substring(
					directoryReleaseName.indexOf("[") + 1,
					directoryReleaseName.indexOf("]")).trim();
		} else {
			releaseName = directoryReleaseName.substring(
					directoryReleaseName.indexOf("-") + 7).trim();
		}
	}

	public String getArtistName() {
		return artistName.toUpperCase();
	}

	public void setArtistName(String artistName) {
		this.artistName = artistName;
	}

	public String getYear() {
		return year;
	}

	public int getYearInInt() {
		return Integer.parseInt(year);
	}
	
	public void setYear(String year) {
		this.year = year;
	}

	public String getReleaseName() {
		return ConversionTexte.capitalize(releaseName);
	}

	public void setReleaseName(String releaseName) {
		this.releaseName = releaseName;
	}

	public String getComplementaryInfo() {
		return complementaryInfo;
	}

	public void setComplementaryInfo(String complementaryInfo) {
		this.complementaryInfo = complementaryInfo;
	}

	public File getDirectoryRelease() {
		return directoryRelease;
	}

	public void setDirectoryRelease(File directoryRelease) {
		this.directoryRelease = directoryRelease;
	}

	public String getFormatReleaseName() {

		return artistName.toUpperCase()
				+ " - "
				+ year
				+ " "
				+ ConversionTexte.capitalize(releaseName)
				+ (complementaryInfo != null ? " [" + complementaryInfo + "]"
						: "");
	}
}
